<%-- 
    Document   : profile
    Created on : Mar 6, 2014, 8:00:28 PM
    Author     : kenn
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<c:set scope="request" var="title" value="Profile"/>

<sql:setDataSource var="ds" driver="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost/bonix"
                   user="root" password=""/>

<sql:query var="profile" dataSource="${ds}">
    SELECT first_name, last_name, bdate, email, contact
    from profile
    where username = '${sessionScope.username}'
</sql:query>


<sql:query var="pass" dataSource="${ds}">
    SELECT username, password
    from accounts
    where username = '${sessionScope.username}'
</sql:query>

<!DOCTYPE html>
<html>
    <jsp:include page="banner.jsp"/>

    <body>
        <jsp:include page="head.jsp"/>

        <div class="row">
            <div class="container">
                <div class="content row">

                    <div class="containerService">

                        <div class="panel panel-primary">
                            <div class="panel-heading">
                                <h3 class="panel-title">ACCOUNT SETTING</h3>
                            </div>

                            <div class="panel-body">
                                <c:forEach var="pr" items="${profile.rows}">
                                    <form action="save.jsp" method="post">
                                        <div class="row">
                                            <div class="col-lg-6">
                                                <label>First Name:</label> 
                                                <input type="text" name="first" value="${pr.first_name}" class="form-control">
                                                <br>
                                            </div>
                                            <div class="col-lg-6">
                                                <label>Last Name: </label>
                                                <input type="text" name="last" value="${pr.last_name}" class="form-control">
                                                <br>
                                            </div>
                                            <div class="col-lg-6">
                                                <label>Contact No.: </label>
                                                <input type="text" pattern="[0-9]*" name="cont" maxlength="11" value="${pr.contact}" class="form-control">
                                                <br>
                                            </div>
                                            <div class="col-lg-6">
                                                <label>Birth Date:</label> 
                                                <input type="date" name="bd" value="${pr.bdate}" class="form-control">   
                                                <br>
                                            </div>
                                            <div class="col-lg-6">
                                                <label>Email Address: </label>
                                                <input type="email" name="em" value="${pr.email}" class="form-control">
                                            </div>
                                        </div>
                                </div><!-- END panel-body -->

                                <div class="panel panel-primary">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">USER CREDENTIAL</h3>
                                    </div>
                                </div>
                                <div class="panel-body">
                                    <c:forEach var="pw" items="${pass.rows}">

                                        <input type="hidden" name="usernam" value="${pw.username}" class="form-control">
                                        <br>

                                        <label>Username:</label> 
                                        <input type="text" name="un" value="${pw.username}" class="form-control" disabled>
                                        <br>

                                        <label>Password:</label>
                                        <input type="password" name="pas" value="${pw.password}" class="form-control">
                                        <br>

                                    </c:forEach>
                                    <button type="submit" class="btn btn-primary">SAVE</button>
                                    </form>
                                </c:forEach>
                            </div><!-- END panel-body -->

                        </div><!-- END panel-primary -->

                    </div><!-- END containerService -->

                </div><!-- END CONTENT CONTENT ROW -->
            </div><!-- END CONTAINER -->
        </div><!-- END ROW -->
    </body>
</html>